//********Rectangle class created by Niv
using namespace std;
#ifndef _RECTANGLE_H_
#define _RECTANGLE_H_
#include<iostream>
#include "PointH.h"
#include <iostream>
#include <Windows.h>
#include "ScreenH.h"
#include "Shape.h"


void gotoxy(int, int);

#define MAX_SCR_WID 80
#define MAX_SCR_LEN 25
#define MIN_SCR_WIDTH 0
#define MIN_SCR_LEN 0

class Rectangl: public Shape
{
	//If Adding Data members, Please remember to update the operator assignment "="
	int m_sizeX, m_sizeY;
	Point m_TL, m_TR, m_BL, m_BR;
	

private:
	void drawRectangle(int option, Screen * s);
	

public:
	
	//Constructors
    Rectangl() 
	{
	    init();
	}

	Rectangl(const Rectangl& copyObj) { *this = copyObj; }; //Copy Constructor

	Rectangl& operator=(const Rectangl& copyObj); //operator =

	void init();


	//serialization

	void saveToFile(ofstream& outf, boolean binary=false);

	void saveToBinFile(ofstream& outf) ;

	void loadFromFile(ifstream& istr, boolean binary=false);

	void saveToTextFile(ofstream& outf ) ;

	void loadFromTextFile(ifstream& outf);

	void loadFromBinFile(ifstream& inf);
	

	//setters
	void setPos(int x, int y);

	void setSize(int x, int y);
	
	void setMoveRectangleWithClashes(int x, int y){};

	//getters

	virtual string getType()const{return "Rectangl";}

	int getSizeX(){return m_sizeX;}

	int getSizeY(){return m_sizeY;}

	void getPos(int &x, int &y);

	void getSize(int &x, int &y);

	void getDir(float &x, float &y);

	Point getPointTL();

	Point getPointTR();

	Point getPointBL();

	Point getPointBR();

	void getPosPointByDirection(int &r_posX, int &r_posY, int r_dir_x, int r_dir_y, Rectangl * r);

	//Help Func
	
	bool isEntirelyContained(Rectangl * rec); // does rec contained within this

	bool pointEntirelyInRectangle(int x, int y);

	void resetPos(int x, int y);

	void drawPoint(char c);
	
	void draw(int drawingOption = 0, Screen * s = NULL);

	bool isPointIn(int x, int y);
	
	void calcRectanglePoint();

	bool isEqual(Rectangl * rec);

	bool isInScreen(int x, int y);
	
	virtual bool isInsideScreen();

	bool isInScreen(Rectangl * r);

	bool isInScreen(Point p);

	void firstResetPosForMove(float x, float y);

	void printRectangleToScreenBuffer(int displayChoice, Screen * s);

	bool isOverlap(Rectangl * rec);

	bool isTangentFromOutside(Rectangl * rec);
	
	bool isTangentFromInside(Rectangl * rec);

	bool isContaining(Rectangl * rec);

	bool isRectangleTouchesRectangle(Rectangl * rec);

	bool isPointTouchesRectangle(int x, int y);

	bool isDirectionsResetBorders();

};


#endif


